# Mocks to make development more convenient
angular.module('upd-merchant-dev', ['upd-merchant', 'ngMockE2E'])

.run ($httpBackend) ->
    $httpBackend.whenPOST(/users\/$/).respond (method, url, data) ->
        data = angular.fromJson data
        if data.password == '123'
            [200, {
                status: '0'
                error: ""
                body: {status: 0, accessToken: "mocktoken"}
            }]
        else
            [200, {status: 0, error: "用户名或密码输入错误"}]

    $httpBackend.whenPOST(/merchant\/register$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: {status: 0, token: "mocktoken"}
        }]
        [400]
    orderItems = [
        {
            id: 1
            img: 'img/mock/good-one.png'
            title: '这个商品有点冷,请小心添加(good-one)'
        }
        {
            id: 2
            img: 'img/mock/good-two.png'
            title: '这个商品有点冷,请小心添加(good-two)'
        }
        {
            id: 3
            img: 'img/mock/good-three.png'
            title: '这个商品有点冷,请小心添加(good-three)'
        }
        {
            id: 4
            img: 'img/mock/good-four.png'
            title: '这个商品有点冷,请小心添加(good-four)'
        }
        {
            id: 5
            img: 'img/mock/good-five.png'
            title: '这个商品有点冷,请小心添加(good-five)'
        }
    ]
    orderList = [
        {
            orderNo: '201509091109113001'
            orderStatus: '未付款'
            orderItems: orderItems
            totalAmt: '4999.00'
        }
        {
            orderNo: '201509091109113001'
            orderStatus: '未付款'
            orderItems: [
                {
                    id: 5
                    img: 'img/mock/good-five.png'
                    title: '这个商品有点冷,请小心添加(good-five)'
                }
            ]
            totalAmt: '4999.00'
        }
        {
            orderNo: '201509091109113001'
            orderStatus: '未付款'
            orderItems: orderItems
            totalAmt: '4999.00'
        }
    ]
    $httpBackend.whenGET(/merchant\/order.*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: orderList
        }]
    classify = [
        {
            key: 0
            value: '全部'
        }
        {
            key: 1
            value: '亲子'
        }
        {
            key: 2
            value: '家电'
        }
        {
            key: 3
            value: '数码'
        }
        {
            key: 4
            value: '旅游'
        }
        {
            key: 5
            value: '小吃'
        }
        {
            key: 6
            value: '运动'
        }
        {
            key: 7
            value: '其他'
        }

    ]
    $httpBackend.whenGET(/merchant\/classify\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: classify
        }]
    $httpBackend.whenGET(/merchant\/classify\/ypk\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: classify
        }]
    $httpBackend.whenGET(/merchant\/orderDetail\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: ''
        }]
    goodsList = [
        {
            img: 'img/mock/good-one.png'
            txt1: '测试较长的商品名称测试较长的商品名称测试较长的商品名称'
            txt2: '商品编号:990001'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }
        {
            img: 'img/mock/good-two.png'
            txt1: '测试商品名称'
            txt2: '商品编号:990002'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }
        {
            img: 'img/mock/good-one.png'
            txt1: '测试商品名称'
            txt2: '商品编号:990003'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }
        {
            img: 'img/mock/good-one.png'
            txt1: '测试商品名称'
            txt2: '商品编号:990004'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }
        {
            img: 'img/mock/good-one.png'
            txt1: '测试商品名称'
            txt2: '商品编号:990005'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }
        {
            img: 'img/mock/good-one.png'
            txt1: '测试商品名称'
            txt2: '商品编号:990006'
            txt3: '库存: 999+'
            txt4: '市场价: 100.00'
            txt5: '会员价: 100.00'
        }

    ]
    ypkGoodList = [
        {
            title: '桃子'
            img: 'img/market/xmt2.png'
            costs: '11.23'
            profit: '4.80'
            unit: '1件'
            hasIt: false
        }

        {
            title: '桃子2'
            img: 'img/market/xmt2.png'
            costs: '11.23'
            profit: '4.80'
            unit: '2个'
            hasIt: true
        }
        {
            title: '桃子3'
            img: 'img/market/xmt.png'
            costs: '100.00'
            profit: '40.00'
            unit: '3斤'
            hasIt: true
        }
        {
            title: '桃子4'
            img: 'img/market/xmt.png'
            costs: '111.11'
            profit: '11.80'
            unit: '4件'
            hasIt: true
        }
        {
            title: '桃子5'
            img: 'img/market/xmt.png'
            costs: '111.11'
            profit: '11.80'
            unit: '5件'
            hasIt: false
        }


    ]
    $httpBackend.whenGET(/merchant\/goodsList\/*$/).respond (method, url, data) ->
        [200, {
            status: '0'
            error: ""
            body: goodsList
        }]
    $httpBackend.whenGET(/merchant\/goodsList\/ypk\/*$/).respond (method, url, data) ->
        [200, {
            status: '0'
            error: ""
            body: ypkGoodList
        }]
    vipList = [
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }
        {
            txt1: '素还真'
            txt2: '13888888888'
        }


    ]
    $httpBackend.whenGET(/merchant\/vipList\/*$/).respond (method, url, data) ->
        [200, {
            status: '0'
            error: ""
            body: vipList
        }]

    messageList = [
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }
        {
            txt1: '消息标题'
            txt2: '这是一条消息简介内容'
            txt3: '2015-11-11 11:11:11'
        }


    ]
    $httpBackend.whenGET(/merchant\/messageList.*/).respond (method, url, data) ->
        [200, {
            status: '0'
            error: ""
            body: messageList
        }]
    $httpBackend.whenGET(/merchant\/mallInfo\/*$/).respond (method, url, data) ->
        [200, {
            status: '0'
            error: ""
            body: {
                mallName: '鱻的商城'
            }
        }]
    $httpBackend.whenGET(/merchant\/banner\/ypk\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: [
                {img: 'img/market/ypk-banner1.png'}
                {img: 'img/market/ypk-banner1.png'}
                {img: 'img/market/ypk-banner1.png'}
            ]
        }]
    $httpBackend.whenGET(/merchant\/banner\/home\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: [
                {img: 'img/home/home-banner1.png'}
                {img: 'img/home/home-banner1.png'}
                {img: 'img/home/home-banner1.png'}
            ]
        }]
    $httpBackend.whenGET(/merchant\/user\/center\/*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: {
                id:''
                tel:'13188888888'
            }
        }]
    goods = {
        title:'梅酒'
        price:'100.00'
        store:'999'
        images:[
            {img:'img/mock/good-one.png'}
            {img:'img/mock/good-two.png'}
            {img:'img/mock/good-three.png'}
        ]
        descImages:[
            {img:'img/mock/good-two.png'}
            {img:'img/mock/good-three.png'}
            {img:'img/mock/good-one.png'}
        ]
        specs:[
            {
                spec:'10mm'
                price:'88.00'
                store:'88'
            }
            {
                spec:'20mm'
                price:'99.00'
                store:'99'
            }
        ]
    }
    $httpBackend.whenGET(/merchant\/goods.*$/).respond (method, url, data) ->
        [200, {
            status: 0
            error: ""
            body: goods
        }]
    $httpBackend.whenPOST(/api\/logout/).respond (method, url, data) ->
        [200]

